;Armory Viewer Updater
;Used to replace the older version with the new downloaded version

; Wait for Armory Viewer to close.
Process, WaitClose, ArmoryViewer.exe
Process, WaitClose, Armory Viewer.exe

; The user installed it
IfExist, installed
{
	; Check if the installer exists
	IfNotExist, aviewer.exe
	{
		MsgBox Exiting (aviewer not found)
		ExitApp
	}
	RunWait, aviewer.exe /S /D=%A_ScriptDir%	; Install to current directory
	FileDelete, aviewer.exe						; Delete installer
}
;The user extracted it
else
{
	;Check if 7-zip downloaded correctly
	IfNotExist, 7z.exe
	{
		MsgBox Exiting (7z not found)
		ExitAPp
	}

	FileMove, aviewer.rar, aviewer.zip	
	RunWait, 7z e -y aviewer.zip	; Extract the files
	FileDelete, aviewer.zip			; Delete the archive
	FileDelete, 7z.exe				; Delete 7-zip
}

; Check for old version
IfExist, Armory Viewer.exe
{
	FileDelete, Armory Viewer.exe
}

Run ArmoryViewer.exe	; Launch App When Complete
